import '../helper/dioHelper2.dart';
class CleanObjects{
int ID;
String Guid;
String CreateTM;
int State;
String CarCode;
double Volume;
String UName;
String UPhone;
String Location;
bool UIfQM;
String UQM;
String UQMTM;
String Gps1;
String TM1;
String Img1;
String Gps2;
String TM2;
String Img2;
bool IfSYQM;
String SYQM;
String SYQMTM;
bool IfHDQM;
String HDQM;
String HDQMTM;
String QMUserId;

CleanObjects(this.ID,this.Guid,this.CreateTM,this.State,this.CarCode,this.Volume,this.UName,this.UPhone,this.Location,this.UIfQM,this.UQM,this.UQMTM,this.Gps1,this.TM1,this.Img1,this.Gps2,this.TM2,this.Img2,this.IfSYQM,this.SYQM,this.SYQMTM,this.IfHDQM,this.HDQM,this.HDQMTM,this.QMUserId);
CleanObjects.fromJson(Map<String,dynamic> json)
:ID=json["ID"],Guid=json["Guid"],CreateTM=json["CreateTM"],State=json["State"],CarCode=json["CarCode"],Volume=json["Volume"]*1.0,UName=json["UName"],UPhone=json["UPhone"],Location=json["Location"],UIfQM=json["UIfQM"],UQM=json["UQM"],UQMTM=json["UQMTM"],Gps1=json["Gps1"],TM1=json["TM1"],Img1=json["Img1"],Gps2=json["Gps2"],TM2=json["TM2"],Img2=json["Img2"],IfSYQM=json["IfSYQM"],SYQM=json["SYQM"],SYQMTM=json["SYQMTM"],IfHDQM=json["IfHDQM"],HDQM=json["HDQM"],HDQMTM=json["HDQMTM"],QMUserId=json["QMUserId"];
Map<String,dynamic> toJson()=>
{'ID':ID,'Guid':Guid,'CreateTM':CreateTM,'State':State,'CarCode':CarCode,'Volume':Volume,'UName':UName,'UPhone':UPhone,'Location':Location,'UIfQM':UIfQM,'UQM':UQM,'UQMTM':UQMTM,'Gps1':Gps1,'TM1':TM1,'Img1':Img1,'Gps2':Gps2,'TM2':TM2,'Img2':Img2,'IfSYQM':IfSYQM,'SYQM':SYQM,'SYQMTM':SYQMTM,'IfHDQM':IfHDQM,'HDQM':HDQM,'HDQMTM':HDQMTM,'QMUserId':QMUserId,};
  static Future<bool> Add(CleanObjects x1) async {
    var response = await DioHelper.Post("/Clean/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(CleanObjects x1) async {
    var response = await DioHelper.Post("/Clean/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(CleanObjects x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/Clean/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<CleanObjects?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/CleanObjects/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200)
      return new CleanObjects.fromJson(response.data);
    return null;
  }

  static Future<CleanObjects?> GetByID(int ID) async {
    var response =
        await DioHelper.Get("/Clean/GetByID?ID=" + ID.toString(), {});

    if (response.statusCode == 200)
      return new CleanObjects.fromJson(response.data);
    return null;
  }

  static Future<List<CleanObjects>> GetList(int pageIndex, int pageSize) async {
    var response = await DioHelper.Get(
        "/Clean/GetList?p1=" +
            pageIndex.toString() +
            "&ps=" +
            pageSize.toString(),
        {});

    var list1 = <CleanObjects>[];
    if (response.statusCode == 200) {
      //print(response.data);
      if (response.data == null) return list1;
      for (var x in response.data) {
        list1.add(new CleanObjects.fromJson(x));
      }
    }
    return list1;
  }


    static Future<List<CleanObjects>> GetListByPhone(int pageIndex, int pageSize,String phone) async {
    var response = await DioHelper.Get(
        "/Clean/GetListByPhone?p1=" +
            pageIndex.toString() +
            "&ps=" +
            pageSize.toString()+"&ph=" +
            phone,
        {});

    var list1 = <CleanObjects>[];
    if (response.statusCode == 200) {
      //print(response.data);
      if (response.data == null) return list1;
      for (var x in response.data) {
        list1.add(new CleanObjects.fromJson(x));
      }
    }
    return list1;
  }


  static Future<List<CleanObjects>> GetAllList() async {
    var response = await DioHelper.Get("/CleanObjects/GetAllList", {});
    var list1 =  <CleanObjects>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new CleanObjects.fromJson(x));
      }
    }
    return list1;
  }
}
